package com.nvwa.coding.function;

import com.nvwa.coding.util.safe.Coding;

import java.util.function.Function;


@FunctionalInterface
public interface FunctionEX<T, U, EX extends Throwable> {

    U apply(T t) throws EX;

    default Function<T, U> toSilentFunction(U orElse) {
        return t -> Coding.silentGetOrElse(() -> apply(t), orElse);
    }

    default Function<T, U> toLoggingFunction(U orElse) {
        return t -> Coding.loggingGetOrElse(() -> apply(t), orElse);
    }

}
